﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess;
using System.Data;
namespace BusinessLogic
{
    class BusinessFacade
    {
        DataFacade facade;
        
        public BusinessFacade()
        {
            facade = new DataFacade();
        }

        public List<ItemType> getListItemType()
        {
            List<ItemType> itList = new List<ItemType>();
            DataTable tbl = facade.getItemType();
            foreach (DataRow r in tbl.Rows)
            {
                ItemType it = new ItemType(r[0].ToString(), r[1].ToString(), r[2].ToString());
                itList.Add(it);
            }
            return itList;
        }
        public List<Items> getTop24ListItemsMedicine()
        {
            List<Items> iList = new List<Items>();
            DataTable tbl = facade.getTop24ItemsMedicine();
            foreach (DataRow r in tbl.Rows)
            {
                Items i = new Items(r[0].ToString(), r[1].ToString(), r[2].ToString(), r[3].ToString(),
                    r[4].ToString(), r[5].ToString(), r[6].ToString(), r[7].ToString(),
                    r[8].ToString(), r[9].ToString(), r[10].ToString(), r[11].ToString());
                iList.Add(i);

            }
            return iList;
        }
        public List<Items> getTop24ListItemsMachine()
        {
            List<Items> iList = new List<Items>();
            DataTable tbl = facade.getTop24ItemsMachine();
            foreach (DataRow r in tbl.Rows)
            {
                Items i = new Items(r[0].ToString(), r[1].ToString(), r[2].ToString(), r[3].ToString(),
                    r[4].ToString(), r[5].ToString(), r[6].ToString(), r[7].ToString(),
                    r[8].ToString(), r[9].ToString(), r[10].ToString(), r[11].ToString());
                iList.Add(i);

            }
            return iList;
        }

        public List<Items> getListItems()
        {
            List<Items> iList = new List<Items>();
            DataTable tbl = facade.getItems();
            foreach (DataRow r in tbl.Rows)
            {
                Items i = new Items(r[0].ToString(), r[1].ToString(), r[2].ToString(), r[3].ToString(),
                    r[4].ToString(), r[5].ToString(), r[6].ToString(), r[7].ToString(),
                    r[8].ToString(), r[9].ToString(), r[10].ToString(), r[11].ToString());
                iList.Add(i);

            }
            return iList;
        }
    }
}
